package com.qf.fmall.index.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.fmall.index.entity.Category;
import com.qf.fmall.index.entity.IndexImg;
import com.qf.fmall.index.entity.Product;
import com.qf.fmall.index.service.ICategoryService;
import com.qf.fmall.index.service.IIndexImgService;
import com.qf.fmall.index.service.IProductService;
import com.qf.fmall.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 轮播图 前端控制器
 * </p>
 *
 * @author leon
 * @since 2024-01-17
 */
@RestController
@CrossOrigin
@RequestMapping("/index")
public class IndexImgController {

    @Autowired
    private IIndexImgService iIndexImgService;

    @Autowired
    private ICategoryService categoryService;

    @Autowired
    private IProductService productService;

//    @Autowired
//    private ICategoryRecommends categoryRecommends;




    @RequestMapping("/indeximg")
    public ResultVo indeximg(){

        QueryWrapper<IndexImg>queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("status",1);

        queryWrapper.orderByAsc("seq");

        List<IndexImg> data = iIndexImgService.list(queryWrapper);

        return new ResultVo(10000,"success",data);

    }


    @RequestMapping("/category-list")
    public ResultVo categoryList (){
      List<Category> data = categoryService.categoryList();

      return new ResultVo(10000,"success",data);

    }


    @RequestMapping("/list-recommends")
    public ResultVo listRecommends (){

    List<Product> data =  productService.listRecommends();

    return new ResultVo(10000,"success",data);
    }


    @RequestMapping("/category-recommends")
    public ResultVo categoryRecommends(){
       List<Category> data = categoryService.categoryRecommends();
        return new ResultVo(10000,"success",data);

    }
}
